package tests;

import Model.PeriodicTask;
import junit.framework.TestCase;
import org.junit.Test;

/**
 * Unit test for a single periodic task
 *
 * @author psyomn
 */
public class PeriodicTaskTest extends TestCase {
    
    @Test
    public void testRemoveName() throws Exception {
        PeriodicTask ptask =  new PeriodicTask("test", new java.sql.Date(0), "Periodic");
        ptask.removeName("test");
        assertEquals(ptask.getName(), "");
    }

    @Test
    public void testSetDone() throws Exception {
        PeriodicTask ptask =  new PeriodicTask("test", new java.sql.Date(0), "Periodic");
        ptask.setDone(true);
        assertTrue(ptask.getDone());
    }

    @Test
    public void testSetName() throws Exception {
        PeriodicTask ptask =  new PeriodicTask("test", new java.sql.Date(0), "Periodic");
        ptask.setName("setname");
        assertEquals(ptask.getName(), "setname");
    }

    @Test
    public void testGetName() throws Exception {
        PeriodicTask ptask =  new PeriodicTask("test", new java.sql.Date(0), "Periodic");
        assertEquals(ptask.getName(), "test");
    }

    @Test
    public void testGetDueDate() throws Exception {
        PeriodicTask ptask =  new PeriodicTask("test", new java.sql.Date(0), "Periodic");
        assertEquals(ptask.getDueDate(), new java.sql.Date(0));
    }

    @Test
    public void testGetDueDateString() throws Exception {
        PeriodicTask ptask =  new PeriodicTask("test", new java.sql.Date(0), "Periodic");
        ptask.setRepeat("Weekly");
        assertEquals("Weekly",ptask.getDateString());
    }

    @Test
    public void testGetDone() throws Exception {
        PeriodicTask ptask =  new PeriodicTask("test", new java.sql.Date(0), "Periodic");
        assertFalse(ptask.getDone());
    }

    @Test
    public void testGetType() throws Exception {
        PeriodicTask ptask =  new PeriodicTask("test", new java.sql.Date(0), "Periodic");
        assertEquals(ptask.getType(), "Periodic");
    }
    
    @Test
    public void testSetRepeat () throws Exception {
        PeriodicTask ptask = new PeriodicTask("test", new java.sql.Date(0), "Periodic");
        ptask.setRepeat("Monthly");
        assertEquals(ptask.getRepeat(), "Monthly");
    }
    
}
